<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>支付</title>
	<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/zepto.js" charset="utf-8"></script>
    <link href="<?php echo TEMPLATE_SITE_URL;?>/css/payment.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="contentbox" style="min-height: 740px;">
<?php if(!empty($output['address'])){?>
<div class="addressMain">
        <div class="userInfo">
            <span>收货人：<?php echo $output['address']['name'];?></span><span><?php echo $output['address']['tele'];?></span>
        </div>
        <div class="addressInfo">
        	<?php echo $output['address']['prov_name'];?>
			<?php echo $output['address']['city_name'];?>
			<?php echo $output['address']['dis_name'];?>
        	<?php echo $output['address']['address'];?>
        </div>
        <a href="index.php?act=payment&op=addresslist&order_id=<?php echo $output['order']['id'];?>"><div class="edit"></div></a>
</div>
<?php }else{?>
<div class="addressMain">
		<a href="index.php?act=payment&op=addresslist&order_id=<?php echo $output['order']['id'];?>">
        <div class="userInfo">
            <span>添加收货地址</span>
            <span></span>
        </div>
        <div class="addressInfo">获取地址</div>
        <div class="edit"></div>
        </a>
</div>
<?php }?>
<div class="saleMain">
    <div class="title">拍品信息</div>
    <div class="goodInfo">
        <div class="img" style="background-image: url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);"></div>
        <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']);?></div>
        <div class="endTime"><span>截止时间：</span><span><?php echo date('Y年m月d日 H:i',$output['auction']['end_time']);?></span></div>
    </div>
    <div class="saleArgs">
        <div class="argItem">
            <span>运费：</span>
            <span><?php if($output['auction']['freeship']==1){ echo '卖家包邮';}else{ echo '买家自理';}?></span>
        </div>
        <div class="argItem">
            <span>保证金：</span>
            <span>￥<?php echo $output['auction']['cashprice'];?>元</span>
        </div>
        <div class="argItem">
            <span>成交金额：</span>
            <span>￥<?php echo $output['auction']['leadingprice'];?>元</span>
        </div>
    </div>
</div>

<div class="payMain">
    <div class="payPrice">
        <span>付款金额：</span>
        <span class="h1">￥<?php echo $output['auction']['leadingprice'];?>元</span>
        <span class="payMemo"></span>
    </div>
    <div class="payMethodList">
    	<!-- 开通 needOpen  -->
        <div class="payMethod balance <?php if($output['user']['price']>0){ echo 'selected';}?>" paymentname="balance">
            <div class="checkbox"></div>
            <div class="icon"></div>
            <div class="content">
                <div class="title">余额支付</div>
                <div class="desc">可用余额：￥ <?php echo $output['user']['price'];?> 元</div>
            </div>
            <div class="open">
            <?php if(empty($output['user']['paypasswd'])){?>
            <a href="index.php?act=payment&op=kaitong&user_id=<?php echo $output['user']['user_id'];?>&order_id=<?php echo $output['order']['id'];?>">开通</a>
            <?php }else{?>
            <a href="index.php?act=payment&op=recharge">充值</a>
            <?php }?>            
            </div>
        </div>
        <div class="payMethod weixin <?php if($output['user']['price']<=0){ echo 'selected';}?>" paymentname="weixin">
            <div class="checkbox"></div>
            <div class="icon"></div>
            <div class="content">
                <div class="title">微信支付</div>
                <div class="desc">使用微信支付，简单方便</div>
            </div>
        </div>
    </div>
    <p><font color="red" id="error_tip" style="padding-left:20px;"></font></p>
    <div class="payBtn">
    	<?php if(!empty($output['address'])){?>
    	<input type="hidden" name="address" value="<?php echo $output['address']['id'];?>">
    	<input type="hidden" name="paymentname" value="<?php if($output['user']['price']>0){ echo 'balance';}else{ echo 'weixin';}?>">
        <div class="submit">安全支付</div>
        <?php }else{?>
        <div class="address">选择收货地址</div>
        <?php }?>
    </div>
    
</div>
</div>
<script type="text/javascript">
$(function(){
	$('.payMethod').click(function(){
		$('.payMethod').removeClass('selected');
		$(this).addClass('selected');
		var paymentname = $(this).attr('paymentname');
		$('input[name=paymentname]').val(paymentname);
	});

	$('.address').click(function(){
		location.href = 'index.php?act=payment&op=addressadd&order_id='+<?php echo $output['order']['id'];?>;
	});	

	$('.submit').click(function(){
		var order_id = '<?php echo $_GET['order_id'];?>';
		var paymentname = $('input[name=paymentname]').val();
		var user_id = '<?php echo $output['user']['user_id'];?>';
		var address = $('input[name=address]').val();

		if(paymentname=='weixin'){
			location.href = 'index.php?act=payment&op=weixin&order_id='+order_id+'&address='+address;
			return false;
		}
		
		$.ajax({
			type:'post',
			url:'index.php?act=payment&op=payment',
			data:{order_id:order_id,paymentname:paymentname,address:address},
			dataType:'json',
			success:function(data){
				if(data.state==1){
					location.href = 'index.php?act=payment&op=balancepayment&order_id='+order_id;
				}else if(data.state==2){
					location.href = 'index.php?act=payment&op=kaitong&user_id=<?php echo $output['user']['user_id'];?>&order_id=<?php echo $output['order']['id'];?>';
				}else{
					$('#error_tip').html(data.error);		
				}
				return false;
			}	
		});
	});	
});
</script>
</body>
</html>